const btnLogin = document.querySelector("#btn-login");

btnLogin.addEventListener("click", async function (e) {
    const username = document.querySelector("#input-email").value.trim();
    const password = document.querySelector("#input-password").value.trim();

    if (!username || !password) {
        document.querySelector('#myToast .toast-body').innerHTML = "账号或密码不能为空！";
        myToast.show()
        return
    } else if (username.length < 2 || password.length < 6) {
        document.querySelector('#myToast .toast-body').innerHTML = "账号长度为2~30且密码不小于6！";
        myToast.show()
        return
    }

    const res = await axios({
        url: '/login',
        method: 'post',
        data: {
            username,
            password
        }
    })

    localStorage.setItem("get00001token", res.data.data.token);
    setTimeout(() => {
        location.href = 'index.html'
    }, 1500)
})